{
  // promise 链式写法
  function p1() {
    return new Promise((resolve, reject) => {
      resolve('p1')
    })
  }
  function p2(data) {
    return new Promise((resolve, reject) => {
      resolve('p2' + data)
    })
  }
  function p3() {
    return new Promise((resolve, reject) => {
      reject('p3')
    })
  }
  // try-catch捕获错误
  async function fun () {
    try {
      console.log('wrong start')
      await p3()
      console.log('p3p3p3p3___________') // 不执行，一旦reject,后面的同步操作将停止
    } catch (error) {
      console.log('_++++++++++++++++++++++++++++' ,error)
    }
    return await p1()
  }
  fun() // p3
  // catch方式捕获错误
  async function fun2 () {
    await p1()
    await p3()
  }
  fun2().catch(err => console.log('err ', err))

  // Promis.all并行两个任务
  async function fun3 () {
    const [re1, re2] =await Promise.all([p1(), p2()])
    console.log('aaaaaaaaaaaaaaa', re1, re2)
  }
  fun3()

}